//
// Created by juno on 2021/9/7.
//
#include <stdio.h>
#include <ctype.h>
#include <libwebsockets.h>

#include "ws_server.h"
#include "http.h"
#include "common.h"

static struct chart_room *rooms = NULL;

int http_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
{
    struct pss *pss = (struct pss *)user;
    uint8_t buf[LWS_PRE + LWS_RECOMMENDED_MIN_HEADER_SPACE], *start = &buf[LWS_PRE],
                *p = start, *end = &buf[sizeof(buf) -1];

    int status = -1;

    switch(reason)
    {
        case LWS_CALLBACK_HTTP:
            {
                if (!strcmp((const char *)in, "/chart")) // FORM
                {
                    return 0;
                }

                if (!strcmp((const char *)in, "/chart_room/list_rooms")) // GET
                {
                    return 0;
                }

                if (!strcmp((const char *)in, "/chart_room/create_room"))  // POST
                {
                    return 0;
                }
            }
            break;
        case LWS_CALLBACK_HTTP_BODY:

            break;
        case LWS_CALLBACK_CLOSED_HTTP:
            break;
        case LWS_CALLBACK_HTTP_BODY_COMPLETION:
            break;
        case LWS_CALLBACK_HTTP_DROP_PROTOCOL:
            break;
        default:
            break;
    }
    return lws_callback_http_dummy(wsi, reason, user, in, len);
}

